package rt

import (
	"fmt"
	"strings"
	"kumachan/standalone/rx"
)


type Program struct {
	Metadata     ProgramMetadata
	Functions    [] FunctionSeed
	ThunkSeq     [] uint
	Effects      [] uint
	DispatchDef  DispatchTableDefMapping
	RpcConf      RpcConf
	Attachments  ProgramAttachments
}
type ProgramMetadata struct {
	EntryModulePath  string
}
type ProgramAttachments struct {
	InjectedEffects  [] func(interface{})(rx.Observable)
}
func (p *Program) InjectEffect(e func(interface{})(rx.Observable)) {
	var inject_list = &(p.Attachments.InjectedEffects)
	*inject_list = append(*inject_list, e)
}

type DataValue interface {
	fmt.Stringer
	ToValue()  Value
}

func (p Program) String() string {
	var i = 0
	var buf strings.Builder
	buf.WriteString(";; program begin\n")
	for _, item := range p.Functions {
		fmt.Fprintf(&buf, "[%d] %s\n", i, item.String())
		i += 1
	}
	buf.WriteString(";; program end\n")
	return buf.String()
}


